﻿using System;
using System.Collections.Generic;
using System.Text;


public class StrCtrl
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="strFileName"></param>
    /// <returns></returns>
    public static string GetFileName(string strFileName)
    {

        strFileName = strFileName.Substring(0, strFileName.LastIndexOf('.'));
        return strFileName;

    }

    public static string ListToString(List<string> list1)
    {
        string strReturn = "";
        for (int i = 0; i < list1.Count; i++)
        {
            strReturn += list1[i] + "\n";
        }
        return strReturn;
    }

    /// <summary>
    /// 提取字符串
    /// </summary>
    /// <param name="strIn"></param>
    /// <param name="strBiaodashi"></param>
    /// <returns></returns>
    public static List<string> FetchString(string strIn, string strBiaodashi)
    {
        int intTmp = 0;
        int intTmpPosition = 0;
        string strTmp = "";
        strTmp = strIn;

        System.Collections.Generic.List<int> list1 = new List<int>();
        System.Collections.Generic.List<string> list2 = new List<string>();

        intTmp = strTmp.IndexOf(strBiaodashi);
        intTmpPosition = intTmp;

        while (intTmp != -1)
        {
            list1.Add(intTmpPosition);
            strTmp = strTmp.Substring(intTmp + strBiaodashi.Length, strTmp.Length - (intTmp + strBiaodashi.Length));
            intTmp = strTmp.IndexOf(strBiaodashi);
            intTmpPosition = strTmp.IndexOf(strBiaodashi) + intTmpPosition + strBiaodashi.Length; ;
        }




        strTmp = strIn;
        for (int i = 0; i < list1.Count; i++)
        {
            if (i == list1.Count - 1)
            {
                list2.Add(strTmp.Substring(list1[i], strTmp.Length - list1[i]));
            }
            else
            {
                list2.Add(strTmp.Substring(list1[i], list1[i + 1] - list1[i]));

            }
        }


        return list2;
    }

}

